package com.luo.shop.service.impl;

import com.luo.shop.dao.AddressDao;
import com.luo.shop.dao.UserDao;
import com.luo.shop.pojo.Address;
import com.luo.shop.pojo.User;
import com.luo.shop.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    private AddressDao addressDao;

    public List<Address> queryByUid(Long uid) {
        Address address = new Address();
        address.setUserId(uid);
        return addressDao.select(address);
    }

    @Transactional
    public Integer save(Address address) {
        Address address1= new Address();
        address1.setUserId(address.getUserId());
        addressDao.delete(address1);
        return addressDao.insertSelective(address);
    }

    public Integer update(Address address) {
       return addressDao.updateByPrimaryKey(address);
    }
}
